package com.combetter.changxing.ui.activity;

import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.combetter.changxing.R;
import com.combetter.changxing.databinding.ActivityMessageBinding;
import com.combetter.changxing.ui.base.BaseActivity;
import com.combetter.changxing.viewmodel.MessageViewModel;


/**
 * 类名  消息列表
 * 作者  tlfx: Sean.guo
 * 日期  2018/9/17 14:35
 */
public class MessageActivity extends BaseActivity<ActivityMessageBinding, MessageViewModel> {

    @Override
    public int setLayout() {
        return R.layout.activity_message;
    }

    @Override
    public Class createViewModel() {
        return MessageViewModel.class;
    }

    @Override
    public void loadData() {
        mBinding.srlContent.autoRefresh();
    }

    @Override
    public void init() {
        initRefreshView();
    }

    /**
     * 刷新控件
     */
    private void initRefreshView() {
        /**
         *  下拉刷新
         */
        mBinding.srlContent.setDisableContentWhenRefresh(true);
        mBinding.srlContent.setHeaderHeight(80);
        mBinding.srlContent.setRefreshHeader(new ClassicsHeader(this));
        mBinding.srlContent.setOnRefreshListener(refreshlayout -> mViewModel.getMsgList(mBinding.srlContent));
    }

}
